//
//  CustomBaseTableView.h
//  Etion
//
//  Created by JingXing Wu on 11-11-9.
//  Copyright (c) 2011年 GuangZhouXuanWu. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "XUITableViewCell.h"

#import "XUIRefreshHeaderView.h"

#import "XUILoadMoreFootView.h"

#import "XUISearchBar.h"

#import "UIColorExtend.h"

#define TABLEBACKGROUNDCOLOR RGBCOLOR(245.0,245.0,245.0)
#define TABLESEPERATORCOLOR RGBCOLOR(116.0,116.0,116.0)
#define TABLECELLSELECTEDCOLOR RGBCOLOR(143.0,193.0,255.0)//(203.0,232.0,250.0)

#define CUSTOMBASETABELVIEWCELLHEIGHT       50

#define CUSTOMBASETABLEVIEWSECTIONHEADHEIGHT        24

#define MAINTITLEFONTSIZE       16
#define SUBTITLEFONTSIZE        13
#define THIRDTITLEFONTSIZE      11

#define MAINTITLEFONT       [UIFont systemFontOfSize:MAINTITLEFONTSIZE]
#define SUBTITLEFONT        [UIFont systemFontOfSize:SUBTITLEFONTSIZE]
#define THIRDTITLEFONT      [UIFont systemFontOfSize:THIRDTITLEFONTSIZE]

typedef NS_ENUM(NSUInteger,XUITabelViewStyleType)
{
    XUITabelViewStyleTypeNone = 256,
    XUITabelViewStyleTypeRefresh = 1,
    XUITabelViewStyleTypePlain = 2,
    XUITabelViewStyleTypeGroup = 4,
    XUITabelViewStyleTypeSearch = 8,
    XUITableViewStyleTypeLoadMore = 16
} ;

@class XUITableView;

@protocol XUITableViewDelegate <UITableViewDelegate>

@optional

- (void)loadMoreContentOfTableView:(XUITableView *)tableview;

- (void)tableView:(XUITableView *)tableview didClickedLoadMoreFootView:(XUILoadMoreFootView *)sender;

- (BOOL)loadingMoreContentOfTableView:(XUITableView *)tableview;

- (UIEdgeInsets)tableView:(XUITableView *)tableView setSeparatorInsetForRowAtIndexPath:(NSIndexPath *)indexPath;

- (void)tableView:(XUITableView *)tableview refreshTableContent:(void(^)())asyncEndRefreshing;

- (id)contentLastRefreshUpdateTimeOfTableView:(XUITableView *)tableview;

@end

@interface XUITableView : UITableView <XUIRefreshHeaderViewDelegate, XUILoadMoreFootViewDelegate>
{
    XUIRefreshHeaderView *_refreshHeaderView;
    
    XUISearchBar *_searchBar;
    
    XUILoadMoreFootView *_loadMoreView;
    
    BOOL _enableRefreshHead;
}

@property(nonatomic, assign) id <XUITableViewDelegate> delegate;

@property(nonatomic, readonly) XUIRefreshHeaderView *refreshHeaderView;

@property(nonatomic, readonly) XUISearchBar *searchBar;

@property(nonatomic, readonly) NSMutableDictionary *dicCellhead;

@property(nonatomic, readonly) XUILoadMoreFootView *loadMoreView;

@property(nonatomic, assign) BOOL separatorExistFollowCell;

- (void)createRefreshHead;

- (void)removeRefreshHead;

- (void)createSearchBar;

- (void)createLoadMoreView;

- (void)removeLoadMoreView;

- (void)loadMoreViewRefreshScrollViewDidScroll:(UIScrollView *)scrollView;

- (void)loadMoreViewRefreshScrollViewDidEndDragging:(UIScrollView *)scrollView;

- (void)selectRowAtIndexPath:(NSIndexPath *)indexpath;

- (void)deselectRowAtIndexPath:(NSIndexPath *)indexpath;

- (void)showRefreshView;

- (void)hideRefreshView;

- (void)showLoadMoreStatus;

- (void)hideLoadMoreStatus;

-(void)showMenuAtCell:(XUITableViewCell*)cell;

-(void)resignFirstResponderMenuAtCell;

-(XUITableViewCell*)findVisibleCellWithTag:(NSString*)szTag;

-(CGFloat)heightForRowAtIndexPath:(NSIndexPath*)indexPath;

-(void)setHeight:(CGFloat)height forRowAtIndexPath:(NSIndexPath*)indexPath;

@end
